/*
 * Copyright 2002-2015 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.core;

/**
 * {@code Ordered} is an interface that can be implemented by objects that
 * should be <em>orderable</em>, for example in a {@code Collection}.
 *
 * 本接口应该被那些 具有排序功能（orderable） 的对象实现，比如在集合里。
 *
 * <p>The actual {@link #getOrder() order} can be interpreted as prioritization,
 * with the first object (with the lowest order value) having the highest
 * priority.
 *
 * 实际从 getOrder() 获取到的值可以理解为 优先级。
 * 规则是：第一个对象（具有最低的顺序值）具有最高优先级。
 * i.e. 数字越低，优先级越高。
 *
 * <p>Note that there is also a <em>priority</em> marker for this interface:
 * {@link PriorityOrdered}. Order values expressed by {@code PriorityOrdered}
 * objects always apply before same order values expressed by <em>plain</em>
 * {@link Ordered} objects.
 *
 * 注意：本接口同时还有一个优先级标志的接口 PriorityOrdered.
 * 由 PriorityOrdered 对象表示的顺序值始终应用于由普通 Ordered 对象表示的相同顺序值之前。
 * （i.e. 先通过 getOrder() 得到的值判断优先级；再根据 PriorityOrdered 优先 Ordered ）
 *
 * <p>Consult the Javadoc for {@link OrderComparator} for details on the
 * sort semantics for non-ordered objects.
 *
 * 有关 非有序对象（non-ordered） 的排序语义（semantics）的详细信息，请
 * 咨询（consult） javadoc 中关于 OrderComparator。
 *
 * 我的理解：
 * 1.通常用于集合对象中的排序！
 * 2.关于排序的规则：
 * 	2.1. 数字越小优先级越高；
 * 	2.2. 当数字相同时，PriorityOrdered 的实现者优先于 Ordered 的实现者。
 * 	（从 PriorityOrdered 来看，这个接口什么都没做，作用为简单的规定同数字时的优先级策略）
 *
 * @author Juergen Hoeller
 * @author Sam Brannen
 * @since 07.04.2003
 * @see PriorityOrdered
 * @see OrderComparator
 * @see org.springframework.core.annotation.Order
 * @see org.springframework.core.annotation.AnnotationAwareOrderComparator
 */
public interface Ordered {

	/**
	 * Useful constant for the highest precedence value.
	 * 用于最高优先级的有用常量（其实就是 MIN_VALUE）
	 * @see java.lang.Integer#MIN_VALUE
	 */
	int HIGHEST_PRECEDENCE = Integer.MIN_VALUE;

	/**
	 * Useful constant for the lowest precedence value.
	 * 用于最低优先级的有用常量（其实就是 MAX_VALUE）
	 * @see java.lang.Integer#MAX_VALUE
	 */
	int LOWEST_PRECEDENCE = Integer.MAX_VALUE;


	/**
	 * Get the order value of this object.
	 * <p>Higher values are interpreted as lower priority. As a consequence,
	 * the object with the lowest value has the highest priority (somewhat
	 * analogous to Servlet {@code load-on-startup} values).
	 * <p>Same order values will result in arbitrary sort positions for the
	 * affected objects.
	 *
	 * 相同的 排序值 会 导致（result in） 受影响的对象位置任意（arbitrary）排序。
	 *
	 * @return the order value
	 * @see #HIGHEST_PRECEDENCE
	 * @see #LOWEST_PRECEDENCE
	 */
	int getOrder();

}
